<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('goods/index')}">{:lang('ADMIN_GOODS_INDEX')}</a></li>
			<li><a href="{:url('goods/add')}">{:lang('ADMIN_GOODS_ADD')}</a></li>
            <li><a href="{:url('goods/edit', array('id' => I('request.id/s',''),'type'=>I('request.type')))}">{:lang('ADMIN_GOODS_EDIT')}</a></li>
            <li class="active"><a href="{:url('goods/attribute', array('id' => I('request.id', ''),'type'=>I('request.type')))}">{:lang('GOODS_ATTRIBUTE')}</a></li>
            <li><a href="{:url('goods/ability', array('id' => I('request.id', ''),'type'=>I('request.type')))}">{:lang('GOODS_ABILITY')}</a></li>
		</ul>
		<form action="{:url('Goods/attribute_post')}" class="js-ajax-form" method="post" >
        	<php>$status = array('1' => '下架', '0' => '上架');</php>
           	<input type="hidden" name="goods_id" value="{:input('request.id', 0, 'intval')}" />
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th>{:lang('ATTRIBUTE_NAME')}</th>
						<th>{:lang('SORT')}</th>
						<th width="100px"><a class="btn btn-primary" href="javascript:void(0)" onClick="addAttr()">{:lang('ADD_ATTRIBUTE')}</a></th>
					</tr>
				</thead>
				<tbody>
					<foreach name="results" item="vo">
					<tr class="attribute">
						<td><input type="text" name="name[]" placeholder="请输入属性名" value="{$vo.att_name}" /></td>
						<td><input type="text" name="order[]" placeholder="请输入排序" value="{$vo.listorder}" /></td>
						<td>
                            <a href="javascript:void(0)" onClick="$(this).closest('tr').remove();">移除</a>
						</td>
					</tr>
					</foreach>
				</tbody>
			</table>
			<div class="form-actions">
				<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
				<a class="btn" href="javascript:history.back(-1);">{:lang('BACK')}</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
    <script type="text/javascript">
		
		function addAttr(){
			var lid = $(".attribute").length;
			if(lid >= 4){
				artdialog_alert("最多允许创建四条属性");
				return false;
			}
			var html = $('#add_attribute').html();
			//html = html.replace(/\{id\}/g, lid);
			$(".table tbody").append(html);
		}
	</script>
    <script type="text/html" id="add_attribute">
		<tr class="attribute">
			<td><input type="text" name="name[]" placeholder="请输入属性名" /></td>
			<td><input type="text" name="order[]" placeholder="请输入排序" /></td>
			<td>
            	<a href="javascript:void(0)" onClick="$(this).closest('tr').remove();">移除</a>
			</td>
		</tr>
	</script>
</body>
</html>